#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <set>
#include <map>
using namespace std;
class Solution {
public:
    int maxSubArray(vector<int>& nums) {
        int max, now;
        max = now = 0;
        for (int i : nums)
        {
            now += i;
            max = max > now ? max : now;
            if (now < 0)now = 0;
        }
        return max;
    }
};